package day0522;

import java.util.Arrays;
import java.util.Random;
import java.util.Scanner;


public class Test6 {
    public static void main(String[] args) throws InterruptedException {
        int c=exam(3,4);
        System.out.println("回答正确的题目数是："+c +  "。 回答错误的数量是:" + (10-c));
    }

    //定义一个长度为len的String数组。
    //长度相同的数组，存入正确答案
    //长度相同的数组，存入用户的答案
    //循环len次,出len道小学 加减乘除的题，存入到String数组中
    //返回做对的题目数量
    private static int exam(int len, int  range) throws InterruptedException {
        String[]  questions=new String[len];
        System.out.println(Arrays.toString(questions));
        int[]  rightAnswer=new int[len];
        int[]  userAnswer=new int[len];
        Scanner  s=new Scanner(System.in);
        Random ran=new Random();
        int count=0;
        for (int i = 0; i < len; i++ ) {
            String[] quesAndAns=generate(range);
            while(judge(questions, i,quesAndAns[0])){
                quesAndAns=generate(range);
            }
            System.out.println(i);
            System.out.println("A");
           /* //回答问题，并将答案存入userAnswer
           System.out.println(questions[i]);
           int ans=s.nextInt();//输入的答案
           userAnswer[i]=ans;//将输入的答案存入到userAnswer数组
           if(rightAnswer[i] == userAnswer[i]){
               count++;
           }*/
       }
       return count;
    }

    private static String[] generate(int range) {
        String[] rs=new String[2];
        int n=1;
        Scanner s=new Scanner(System.in);
        int num1=s.nextInt();
        int num2=s.nextInt();
        switch (n){
            case 0:
                rs[0]= num1 +  "+" + num2+ "=";
                rs[1]= num1 + num2+"";
                return rs;
            case 1:
                rs[0]= num1 +  "-" + num2+ "=";
                rs[1]= num1 - num2+"";
                return rs;
            case 2:
                rs[0]= num1 +  "*" + num2+ "=";
                rs[1]= num1 * num2+"";
                return rs;
            case 3:
                rs[0]= num1 +  "/" + num2+ "=";
                rs[1]= num1 / num2+"";
                return rs;
            default: return null;
        }
    }


    //judge()： 作用判断questions数组中已经存储的题和num1,num2构成的题是否相同
    private static boolean judge(String[] questions, int num, String ques) {
        for (int j = 0; j < num; j++) {
            if(ques .equals(questions[j])){
                return true;
            }
        }
        return false;
    }

}
